How To Install Nextant Full Text Search For NextCloud

https://github.com/nextcloud/nextant/wiki
and (links to)
https://github.com/nextcloud/nextant/wiki/Setup-your-local-Solr-as-a-Service

To install java depenencies:
https://www.howtoforge.com/tutorial/how-to-install-and-configure-solr-on-ubuntu-1604/

1. Update the system

$ sudo apt-get update && apt-get upgrade -y

2. Install Java

$ sudo add-apt-repository ppa:webupd8team/java

$ sudo apt-get update

$ sudo apt-get install oracle-java8-installer

check the java version:

$ java -version

output example:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

3. Install Solr

mirrors available at:
http://apache.mirror.anlx.net/lucene/solr/6.6.0/solr-6.6.0.tgz
http://www.us.apache.org/dist/lucene/solr/6.6.0/solr-6.6.0.tgz
http://archive.apache.org/dist/lucene/solr/6.0.0/solr-6.6.0.tgz
… and check the root of each of these mirrors for the latest version

$ mkdir ~/solr_install/
$ cd ~/solr_install/
$ wget http://apache.mirror.anlx.net/lucene/solr/6.6.0/solr-6.6.0.tgz
$ tar -zxvf solr-6.6.0.tgz
$ sudo ./solr-6.6.0/bin/install_solr_service.sh solr-6.6.0.tgz

By default, Solr will listen onto every host of your server. There is two ways of fixing this; you can edit the configuration of your Solr or add some iptables rules. I will edit the config:

Ctrl+c to exit the output screen. Then:

$ sudo service solr stop
$ sudo nano /opt/solr/server/etc/jetty-http.xml

modify this line (around line number 36):

 <Set name="host"><Property name="jetty.host" /></Set>

to (substituing ip.address for the ip address of your server, e.g. 192.168.1.90):

 <Set name="host"><Property name="jetty.host" default="ip.address" /></Set>

Ctrl+x then ‘Y' to save and exit.

Also, if you have https and encryption set up, edit the file below:

sudo nano /opt/solr/server/etc/jetty-https.xml

change the line below:

<Set name="host"><Property name="solr.jetty.host" /></Set>

to (substituing ip.address for the ip address of your server, e.g. 192.168.1.90):

<Set name="host"><Property name="solr.jetty.host" default="ip.address" /></Set>

Start the Solr servlet:

$ sudo /etc/init.d/solr start

you should see something like:

Archiving 1 old GC log files to /var/solr/logs/archived
Archiving 1 console log files to /var/solr/logs/archived
Rotating solr logs, keeping a max of 9 generations
Waiting up to 180 seconds to see Solr running on port 8983 [\]
Started Solr server on port 8983 (pid=516). Happy searching!

Now, generate the core that will be used by Nextant:

$ sudo -u solr /opt/solr/bin/solr create -c nextant

you should see something like:

Copying configuration to new core instance directory:
/var/solr/data/nextant

Creating new core 'nextant' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=nextant&instanceDir=nextant

{
  "responseHeader":{
    "status":0,
    "QTime":2867},
  "core":"nextant"}

If you have an error like this: ERROR: Error CREATEing SolrCore ‘nextant': Unable to create core [nextant] Caused by: /var/solr/data/nextant/data you will need to delete your core and try again using the code below:

$ sudo /opt/solr/bin/solr delete -c nextant

After the setup complete, you will need to initiate the first indexing of your files (first, change into the directory where nextcloud is installed):

$ cd /var/www/html/nextcloud
$ sudo -u www-data php ./occ nextant:index

ERRORS & SOLUTIONS

On the github nextant page, it says that the code below should be run to initiate the first indexing of files however, when trying to run I get an error:

$ ./occ nextant:index 

The error is:

sudo: unable to execute ./occ: Permission denied

The solution was to us the modify the code into what was presented above:
https://docs.nextcloud.com/server/9/admin_manual/configuration_server/occ_command.html

$ sudo -u www-data php ./occ nextant:index

Also, it seems that solr will somehow stop for unknown reasons. This happened when I ran the first index with Error #21https://github.com/nextcloud/nextant/wiki/Error-Code – so I had to restart the solr and index again (I had to do this a couple of times).

sudo /etc/init.d/solr start

Then I ran the code below:

$ sudo -u www-data php occ nextant:index --background --unlock

the output to this was:

nextant v1.0.6
A background indexing process is scheduled

Solr continued to crash when trying to index, so I did this:
https://github.com/nextcloud/nextant/issues/116

1. Increased Solr memory
https://github.com/nextcloud/nextant/wiki/Extracting,-Live-Update

Solr will needs memory when you start indexing/querying a descent number of documents, you can increase the allocated pool of memory (default is 512 MB):

edit ‘/etc/default/solr.in.sh'

$ sudo nano /etc/default/solr.in.sh

Ctrl+W and enter ‘solr_heap' to find the line and change to:

SOLR_HEAP="2048m"

Ctrl+X, then ‘Y' to save and exit.

Still didn't work, solr crashed again. Then set the index to run in debug mode:

$ sudo -u www-data php ./occ nextant:index --debug

When solr crashed this time, I was able to see which file during the extracting process was the culprit. In my case, it was a tiddlywiki .html file but it turns out I had to eliminate the entire folder from being indexed.

1. In Nextcloud, go into the folder that you want to exclude from the index. 2. Then click the ‘+' plus sign to add a text file but instead of a text file, create a file with the name ‘.noindex'. This will exclude the folder from Nextant indexing.

After excluding the file with all tiddlywiki .html files, I re-ran the index command and everything ran OK.

When this is done, you have enabled a full-text search within your own files and shared document of your cloud.


The code below produces errors

Optionally, for remote access to the webadmin of your Solr; we will generate a htpasswd file to store your login and password (using ‘admin' as the login_:

$ sudo htpasswd -c /etc/apache2/htpasswd-solr admin

edit the file below:

$ sudo nano /etc/apache2/sites-enabled/nextcloud.conf

add this to your current configuration (inside the <Directory:> </Directory>):

# Solr
ProxyPass /solr/ http://localhost:8983/solr/
ProxyPassReverse /solr/ http://localhost:8983/solr/

<Location /solr/>
  AuthType Basic
  AuthName "solr"
  AuthUserFile /etc/apache2/htpasswd-solr
  Require valid-user
</Location>

To update solr to a new version, you must uninstall solr and then re-install the new version

https://askubuntu.com/questions/680690/how-to-uninstall-solr/680695#680695

replace ‘solr-6.6.0' with the version that you will be uninstalling:

$ sudo service solr stop
$ sudo rm -r /var/solr
$ sudo rm -r /opt/solr-6.6.0
$ sudo rm -r /opt/solr
$ sudo rm /etc/init.d/solr
$ sudo deluser --remove-home solr
$ sudo deluser --group solr

Then go back to Step 3 and repeat the install process.

ALSO SEE:

How To Install Tesseract OCR For Nextant and Nextcloud

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.